package javase_class_250909;

/**
 * ClassName: Planet
 * Package: javase_class_250909
 * Description:
 *
 * @Author harkjeans
 * @Create 2025/9/9 9:16
 * @Version 1.0
 */
public enum Planet {
    // 调用构造函数创建枚举实例
    MERCURY(3.302e+23, 2.439e6),
    VENUS  (4.869e+24, 6.052e6),
    EARTH  (5.975e+24, 6.378e6),
    MARS   (6.419e+23, 3.393e6);

    // 字段
    private final double mass;   // 质量 (kg)
    private final double radius; // 半径 (m)

    public double getMass(){
        return mass;
    }

    // 构造函数 (默认为private，不能是public或protected)
    Planet(double mass, double radius) {
        this.mass = mass;
        this.radius = radius;
    }

    // 方法
    public double surfaceGravity() {
        return G * mass / (radius * radius);
    }

    public double surfaceWeight(double otherMass) {
        return otherMass * surfaceGravity();
    }

    private static final double G = 6.67300E-11;
}

